package com.zzh.wsss.mapper;

import com.zzh.wsss.pojo.Apply;
import com.zzh.wsss.pojo.ApplyMsg;
import com.zzh.wsss.pojo.UserMsg;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface ApplyOperateMapper {

    @Select("select count(*) from apply where user_id=#{userId}")
    Integer getUserApplyNum(@Param("userId") Integer userId);

    @Insert("insert into apply (user_id,job_id,action,info) values (#{userId},#{jobId},#{action},#{info})")
    void addApply(@Param("userId") Integer userId,
                  @Param("jobId") int jobId,
                  @Param("action") int action,
                  @Param("info") String info);

    @Insert("insert into apply (user_id,job_id,action) values (#{userId},#{jobId},#{action})")
    void addApplyNull(@Param("userId") Integer userId,
                  @Param("jobId") int jobId,
                  @Param("action") int action);

    @Select("select * from apply where user_id=#{userId}")
    List<Apply> getApplyResult(@Param("userId") Integer id);

    @Delete("delete from apply where id = #{id}")
    void deleteApply(@Param("id") Integer id);

    @Select("select apply.id,username,job.id as job_id,job_name,action,info " +
            "from user right join apply on user.id= apply.user_id left join job on apply.job_id=job.id" +
            " where results is null")
    List<ApplyMsg> getApplysMsg();


    @Update("update apply set results=#{results} where id=#{id}")
    void applyProcess(@Param("id") int parseInt, @Param("results") int parseInt1);
}
